#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    int maxAscendingSum(vector<int>& nums) {
        vector<int> dp(nums.size(),0);
        int result = INT16_MIN;
        for(int i = 0;i<nums.size();++i){
            if(i==0){
                dp[i] = nums[i];
            }
            else{
                if(nums[i]>nums[i-1]){
                    dp[i] = dp[i-1]+nums[i];
                }
                else{
                    dp[i] = nums[i];
                }
            }
            result = max(result,dp[i]);
        }
        return result;
    }
};

int main(){
    Solution S;
    vector<int> nums = {10,20,30,40,50};
    cout<<S.maxAscendingSum(nums)<<endl;
}

